﻿using System.Windows.Controls;

namespace VoiceMessager.Views
{
	public class AutoScrollListBox : ListBox
	{
		protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
		{
			if (e?.NewItems != null)
			{
				var newItemCount = e.NewItems.Count;
				if (newItemCount > 0) this.ScrollIntoView(e.NewItems[newItemCount - 1]);
				base.OnItemsChanged(e);
			}
		}
	}
}
